<?php

namespace App\Modules\CodeDesigner\AbstractFactoryReflection;

use App\Modules\CodeDesigner\AbstractFactoryReflection\Product\BlackCat;
use App\Modules\CodeDesigner\AbstractFactoryReflection\Product\WhiteCat;
use App\Modules\CodeDesigner\AbstractFactoryReflection\Product\WhiteDog;

class FactoryReflection
{

    public $namespace = 'App\Modules\CodeDesigner\AbstractFactoryReflection\Product\\';

    /**
     * @var string
     */
    private $color;

    public function __construct()
    {
        $this->color = config('code_designer.factory_reflection.color');
    }

    /**
     * @return BlackCat | WhiteCat | object
     * @throws \ReflectionException
     */
    public function createCat()
    {
        $className = $this->namespace . $this->color . 'Cat';
        $class = new \ReflectionClass($className);
        return $class->newInstance();
    }

    /**
     * @return BlackDog | WhiteDog | object
     * @throws \ReflectionException
     */
    public function createDog()
    {
        $className = $this->namespace . $this->color . 'Dog';
        $class = new \ReflectionClass($className);
        return $class->newInstance();
    }
}